<?php
/**
 * +-------------------------------------------------------------
 * |Caption:
 * +-------------------------------------------------------------
 * |Author: Lenny
 * +-------------------------------------------------------------
 * |Email:  1685964109@qq.com
 * +-------------------------------------------------------------
 * |Date:   2024/7/31 上午10:56
 * +-------------------------------------------------------------
 */

declare (strict_types = 1);

namespace app\common\exception;

use think\Exception;

class BaseException extends Exception
{
    /**
     * 状态码
     * @var mixed
     */
    public $status;

    /**
     * 信息
     * @var string
     */
    public $message = '';

    /**
     * 数据信息
     * @var array
     */
    public $data = [];

    public function __construct($params = [])
    {
        parent::__construct();
        if (!is_array($params)) {
            return;
        }
        $this->status  = array_key_exists('status', $params) ? $params['status'] : config('status.error');
        $this->message = array_key_exists('message', $params) ? $params['message'] : '很抱歉，服务器内部错误';
        $this->data    = $params['data'] ?? [];
    }
}